package com.dai.bookkeeping.adapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;
public class RecordPagerAdapter extends FragmentPagerAdapter {
    List<Fragment> fragments;
    String[] titles={"支出","收入"};
    //用构造方法将 List<Fragment> fragments传入
    public RecordPagerAdapter(@NonNull FragmentManager fm,List<Fragment> fragments) {
        super(fm);
        this.fragments=fragments;
    }
    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Nullable
    @Override
    //父类自己的方法，不是自己写的
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
